import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

export default new Vuex.Store({
  state:{
    account:{},
    userinfo:{},
    langs:['zh','en','vi'],
    lang:"en",
    menuList: {}
  },
  mutations:{
    setAccount(state,account){
      state.account = account;
      localStorage.setItem('account',JSON.stringify(account));
    },
    setUserInfo(state,userinfo){
      state.userinfo = userinfo;
      localStorage.setItem('userinfo',JSON.stringify(userinfo));
    },
    setLang(state,lang){
      state.lang = lang;
      localStorage.setItem('lang',lang)
    },
    setmenuList(state,list){
      state.menuList = list;
      localStorage.setItem('menuList',JSON.stringify(list));
    },
    logout(state){
      state.userinfo = {}
      localStorage.removeItem('userinfo')
    }
  },
  actions:{

  }
});
